package com.yyj.dao;

import com.yyj.entity.Params;
import com.yyj.entity.Reserve;
import com.yyj.entity.TimeSelection;
import org.apache.ibatis.annotations.*;

import java.lang.reflect.Array;
import java.util.List;
import java.util.Map;

@Mapper
public interface ReserveDao {
    @Insert("insert into reserve(userName,doctorName,timeSelection,reserveTime,totalPrice,reserveProgress,price) values (#{userName},#{doctorName},#{timeSelection},now(),#{totalPrice},'1',#{price})")
    void establish(Reserve reserve);

    @Select("SELECT timeSelection, COUNT(*) AS appointment_count FROM reserve WHERE doctorName = #{doctorName} GROUP BY doctorName, timeSelection")
    List<TimeSelection> getNum(String doctorName);


    List<Reserve> getReserve(@Param("params") Params params);

    @Select("select * from reserve where userName=#{userName}")
    List<Reserve> getApplication(String userName);

    @Update("update reserve set totalPrice=#{totalPrice},reserveProgress=#{reserveProgress} where id=#{id}")
    void setPrice(Reserve reserve);
    @Delete("DELETE FROM reserve WHERE id = #{id}")
    void delete(Integer id);
}
